##
# Makefile
#
# Copyright 2012 Fabian Wenzelmann
#
# This file is part of ss12-gtprojects.
#
# ss12-gtprojects is free software: you
# can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# ss12-gtprojects is distributed in the hope
# that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ss12-gtprojects.
#
# If not, see <http://www.gnu.org/licenses/>.
##

export GXX = g++ -O3 -Wall
export INCLUDE = include
export HEADERS = $(notdir $(wildcard ${INCLUDE}/**/*))
SRC = src
SOURCES = $(notdir $(wildcard ${SRC}/*.cpp))
EXCLUDES = $(patsubst %.cpp, %.o, $(notdir ${SRC}/Project1Main.cpp))
export OBJECTS = $(filter-out ${EXCLUDES}, $(patsubst %.cpp, %.o, $(SOURCES)))
PROG = project1
INCLUDE_ARGS = ${INCLUDE:%=-I%}
MAIN = src/Project1Main.cpp

all: prog

clean:
	rm -f *.o
	rm -f *.a
	rm -f ${PROG}

%.o: ${SRC}/%.cpp	
	$(GXX) -c $< ${INCLUDE_ARGS}
	
prog: ${OBJECTS}
	$(GXX) -o ${PROG} ${INCLUDE_ARGS} $^ ${MAIN}
	
compile: ${OBJECTS}

lib: compile
	ar -rv libbfr.a *.o

.PRECIOUS: %.o %.a

.PHONY: clean
